package controller;

import dao.BaseDao;
import entity.User;

import javax.servlet.annotation.WebServlet;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class UserMenagement {
    public List<User> GetUserInfo(){
        List<User> list=new ArrayList<User>();

        BaseDao baseDao=new BaseDao();
        try {
            PreparedStatement pstm=baseDao.pstmt("SELECT ShenFenZheng,XingMing,XingBie,TongXunDiZhi,DianHuaHaoMA  FROM chezhuinfo;",null);
            ResultSet rs= pstm.executeQuery();
            while (rs.next()){
                User user=new User();
                user.setId(rs.getString(1));
                user.setName(rs.getString(2));
                user.setAddress(rs.getString(4));
                user.setPhoneNum(rs.getString(5));
                
                list.add(user);
            }
            return list;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
